package com.learner.course.controller.api;

import com.learner.course.service.TeacherService;
import com.learner.pojo.course.Teacher;
import com.learner.pojo.course.expand.PageVariableTeacher;
import com.learner.pojo.page.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author ice2020x
 * @Date: 2023/3/7
 * @Description: 教师的控制器
 **/
@RestController
@RequestMapping("/api/edu/teacher")
public class ApiTeacherController {

    @Autowired
    private TeacherService teacherService;

    /**
     * 获取讲师列表
     *
     * @return 讲师列表
     */
    @GetMapping("/list")
    public List<Teacher> listAll() {
        return teacherService.list();
    }


    /**
     * 获取讲师数据
     *
     * @param id 讲师id
     * @return 结果
     */
    @GetMapping("/get/{id}")
    public Map<String, Object> get(@PathVariable("id") String id) {
        return teacherService.selectTeacherInfoById(id);
    }



    /**
     * 根据条件查询
     * @param pathVariable 参数
     * @return 结果
     */
    @PostMapping("/findAll/condition")
    public PageResult<Teacher> listPage(@RequestBody PageVariableTeacher pathVariable) {
        return teacherService.listPageByPathVariable(pathVariable);
    }

}
